import axios from './axios';
// 首页数据
export function homeGoods(params) {
  return axios({
    url: '/jd/good/cate',
    method: 'get',
    params
  })
}
// 详情页数据
function detailGoods(params) {
  return axios({
    url:'/jd/good/detail',
    method: 'get',
    params
  })
}
// 分类页面数据
function cateGoods(params) {
  return axios({
    url: '/jd/list',
    method: 'get',
    params
  })
}
// 加入购物车
function goodsToCart(params) {
  return axios({
    url: '/jd/cart/add',
    method: 'get',
    params
  })
}
// 购物车数据
function CartData(params) {
  return axios({
    url: '/jd/cart/list',
    method: 'get',
    params
  })
}
// 更新购物车数量
const updateCart = data => {
  return axios({
    url: '/jd/cart/update',
    method: 'post',
    data
  })
}
// 删除商品
const delCartShop = params => {
  return axios({
    url:'/jd/cart/del',
    method: 'get',
    params
  })
}
// 购买商品
const buyGoods = (data) => {
  return axios({
    url: '/jd/cart/submit',
    method: 'post',
    data
  })
}

// banner
const getBanner = () => {
  return axios({
    url: '/jd/get/banner',
    method: 'post'
  })
}

export default {
  homeGoods,
  detailGoods,
  cateGoods,
  goodsToCart,
  CartData,
  updateCart,
  delCartShop,
  buyGoods,
  getBanner
}